//
//  MenuChoiceView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/10/9.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class MenuChoiceView: UIView {
    var bgView:UIScrollView!//背景框
    var label:UILabel!//提示文字
    override init(frame: CGRect) {
        bgView = UIScrollView()
        label = UILabel()
        super.init(frame: frame)
        self.createBGView()
        self.createlabel()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //创建底部背景框 scrollview   并在 最顶部 加一条分割线
    func createBGView(){
        bgView.backgroundColor = Theme.BGColor
        bgView.frame = self.bounds
        self.addSubview(bgView)
        
        let lineView = UIView(frame: CGRectMake(0,0,WidthAPP,0.3))
        lineView.backgroundColor = Theme.GrayColor
        self.addSubview(lineView)
    }
    
    
    
    //创建提示文字
    func createlabel(){
        label.frame = CGRectMake(0, 20*SCALEH, WidthAPP, 15*SCALEH)
        label.text = "请选择您的标签"
        label.textAlignment = .Center
        label.font = BaseFunc.getLightFont(15)
        label.textColor = UIColor.blackColor()
        bgView.addSubview(label)
    }
    
    //创建选项item
    func createButtonItem(menuName:Array<String>){
        for i in 0..<menuName.count{
            let widthCount = CGFloat(i+3)%3
            let heightCount = CGFloat(Int((i+3)/3))
            let itemButton = UIButton(frame: CGRectMake(20*SCALEW+widthCount*118*SCALEW,55*SCALEH*heightCount,100*SCALEW,35*SCALEH))
            itemButton.setTitle(menuName[i], forState: .Normal)
            itemButton.layer.cornerRadius = 8*SCALEW
            itemButton.backgroundColor = BaseFunc.createCustomColor(136, b: 166, g: 216, a: 1)
            itemButton.tag = 5510+i
            itemButton.titleLabel?.font = BaseFunc.getLightFont(14)
            itemButton.setTitleColor(UIColor.whiteColor(), forState: .Normal)
            itemButton.setTitleColor(BaseFunc.createCustomColor(172, b: 58, g: 70, a: 1), forState: .Selected)
            itemButton.selected = false
            self.bgView.addSubview(itemButton)
            
            self.bgView.contentSize = CGSizeMake(WidthAPP, 55*SCALEH+55*SCALEH*(heightCount))
        }
    }
}








